<template>
    <div>
      <artical-item
        v-for="p in postList"
        :key="p.postId"
        :post="p"
      ></artical-item>
      <el-skeleton :loading="loading" :rows="6" animated />
      <el-empty v-if="page.total == 0 && !loading" description="空空如也~"></el-empty>
    </div>
  </template>
  
  <script>
  import postApi from "@/axios/postApi";
  import ArticalItem from "../Artical/ArticalItem.vue";
  import PageMixin from "@/mixins/PageMixin";
  export default {
    
    components: {
      ArticalItem,
    },
    mixins: [PageMixin],
    data() {
      return {
        postList: [],
      };
    },
  
    methods: {
      getList() {
        postApi
          .listByUser({
            current: this.page.current,
            size: this.page.size,
            userId:this.$route.params.userId
          })
          .then(({ data }) => {
            if (data.code === this.$status.SUCCESS_CODE) {
              this.postList = this.postList.concat(data.data.records);
              this.page.current = data.data.current;
              this.page.total = data.data.total;
              this.page.pages = data.data.pages;
              //关闭加载动画
              this.loading = false;
            } else this.$message.error("获取数据出错");
          })
          .catch((e) => {
            console.error(e);
            this.$message.error("获取数据出错");
          });
      },
      load() {
        this.page.current++;
        this.getList();
      },
       
    },
  
    created() {
    
      this.getList();
    },
  };
  </script>
  
  <style>
  </style>